﻿<Window x:Class="_12.BindToList.TreeView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:_12.BindToList"
        xmlns:p11="clr-namespace:_11.DataBinding;assembly=11.DataBinding"
        Title="TreeView" Height="300" Width="300">
    <Window.Resources>
        <!--note: x:Type indicates template for all 'Family' class-->
        <HierarchicalDataTemplate DataType="{x:Type local:Family}"
                                  ItemsSource="{Binding Path=Members}">
            <TextBlock Text="{Binding Path=Name}"/>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="{x:Type p11:Person}"
                                  ItemsSource="{Binding Path=Traits}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=Name}"/>
                <TextBlock Text="(age:"/>
                <TextBlock Text="{Binding Path=Age}"/>
                <TextBlock Text=")"/>
            </StackPanel>
        </HierarchicalDataTemplate>
    </Window.Resources>
    <TreeView  Name="tvFamiles">
        <TreeViewItem ItemsSource="{Binding}" Header="Familes" />
    </TreeView>
</Window>
